<template>
  <el-form ref="formRef" :model="question" label-width="120px">
    <el-form-item label="题目类型">
      <el-select  v-model="question.questionType" placeholder="请选择题目类型">
        <el-option label="单选题" value="0"></el-option>
        <el-option label="多选题" value="1"></el-option>
        <el-option label="判断题" value="2"></el-option>
        <el-option label="纯文字题" value="3"></el-option>
        <el-option label="带图文字题" value="4"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="题目题干">
      <el-input v-model="question.questionContent" :disabled="question.questionType===''"></el-input>
    </el-form-item>
    <el-form-item label="题目答案">
      <el-input v-model="question.answer"></el-input>
    </el-form-item>
    <el-form-item label="上传者编号">
      <el-input v-model="question.userId"></el-input>
    </el-form-item>
    <el-form-item label="题目分数">
      <el-input v-model="question.score"></el-input>
    </el-form-item>
    <el-form-item label="难易程度">
      <el-select  v-model="question.level" placeholder="请选择题目类型">
        <el-option label="简单" value="1"></el-option>
        <el-option label="中等" value="2"></el-option>
        <el-option label="困难" value="3"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="是否为客观题">
      <el-switch
          v-model="question.isObjective"
          active-text="是"
          inactive-text="否"
          active-color="#13ce66"
          inactive-color="#ff4949"
          active-value="1"
          inactive-value="0"/>
    </el-form-item>
    <el-form-item label="专业编号">
      <el-input v-model="question.majorId"></el-input>
    </el-form-item>
    <el-form-item label="备注">
      <el-input v-model="question.remark"></el-input>
    </el-form-item>
    <el-form-item label="题目状态">
      <el-switch
          v-model="question.status"
          active-text="启用"
          inactive-text="停用"
          active-color="#13ce66"
          inactive-color="#ff4949"
          active-value="0"
          inactive-value="2"/>
    </el-form-item>
    <el-form-item>
      <el-button @click="add()">添加</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import {addQuestion} from "@/api/question";

export default {
  name: "AddQuestion",
  data() {
    return {
      props: {
        label:'questionContent',
        value:'id'
      },
      questions:[],
      question:{
        userId:'',
        questionContent:'',
        questionType:'',
        answer:'',
        score:'',
        level:'',
        majorId:'',
        status:0,
        isObjective:1,
        remark:'',
      }
    }
  },
  methods:{
    async add(){
      const rep = await addQuestion(this.question)
      console.log(rep)
    }
  }
}
</script>

<style scoped>

</style>